class SolutionZsh {
    public int maxSubArray(int[] nums) {
        int maxSum = 0;
        int maxValue = Integer.MIN_VALUE;
        for (int item: nums) {
            maxSum += item;
            if (maxSum > maxValue) maxValue = maxSum;
            if (maxSum < 0) maxSum = 0;
        }
        return maxValue;
    }
}